<template>
  <div class="entirety">
    <span @click="goToHome">姚君豪的电商网站Vue3 10/18</span>
    <div class="header-menu-cart" @click="goToShoopingCar">
      购物车
      <span v-show="carlist.length">{{carlist.length}}</span>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, reactive, onMounted, watch } from "vue";
import { useRouter } from "vue-router";
import { useCounterStore } from "../pinia/counter";
const router = useRouter();
const store = useCounterStore();

let carlist = ref([]);

function goToShoopingCar() {
  // router.push({
  //   name: "ShoopingCar",
  // });
  router.push({ path: "/cart" });
}
function goToHome() {
  router.push({ name: "list" });
}

onMounted(() => {
  carlist.value = store.cartList;
});
</script>

<style  scoped>
.entirety {
  width: 100%;
  height: 48px;
  line-height: 40px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 20px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
}

.header-menu-cart {
  color: #fff;
  margin: 0 80px 0 0;
}
.header-menu-cart span {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  background: #ff5500;
  color: #fff;
  font-size: 12px;
}
</style>